home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 1.7 KB | 67 lines | [TEXT/ToyS] |
- property kasOutType : "RSRC" -- Picture file type
- property kasOutApp : "Doug" -- Creator for output file
- property gasResType : "TEXT" -- Default type to get
-
-
- on run
- open {choose file with prompt "Choose a file to extract resources from…"}
- end run
-
-
- on open fsObjs
- set gasResType to the text returned of (display dialog ¬
- ("What type of resource would you like to collect?" & return & ¬
- return & "(Enter the four letter resource type)") ¬
- default answer gasResType with icon note ¬
- buttons {"Cancel", "OK"} default button 2)
-
- set fsObj to item 1 of fsObjs
- set fname to (catalog name of (basic info for fsObj))
- set outFile to a new file in fsObj named fname & "•" & gasResType ¬
- of type kasOutType with creator kasOutApp with resource fork
-
- repeat with fsObj in fsObjs
- DoFile(fsObj, outFile)
- end repeat
- end open
-
-
- on DoFile(fsObj, outFile)
- set fname to catalog name of (basic info for fsObj)
- set rsrcs to (the number of resources in fsObj of type gasResType with their info)
-
- set n to the number of items in rsrcs
- set pg to display progress titled fname maximum n
-
- -- {{rName, rNum, rFlags}, {...}}
- repeat with r in rsrcs
- -- Get resource
- set gotOne to true
- try
- set rsrc to the resource in fsObj of type gasResType ¬
- numbered (item 2 of r)
- on error
- display progress pg labeled ("Error reading: " & (item 2 of r))
- set gotOne to false
- end try
-
- if (gotOne) then
- -- Name?
- copy item 1 of r to rName
- if (rName is "") then set rName to fname & "#" & (item 2 of r)
-
- -- Update progress
- display progress pg value 0 subtitled rName
-
- -- Write to outfile
- save resource rsrc in outFile ¬
- of type gasResType ¬
- named rName
- end if
- end repeat
-
- display progress pg with disposal
- end DoFile
-
-
-